home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 July / macformat-026.iso / mac / Shareware City / Developers / NString 1.0 beta / Sources / Alphabet_Inlines.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-16  |  5.5 KB  |  237 lines  |  [TEXT/KAHL]

  1.  
  2. #ifndef _ALPHABET_INLINES_H_
  3. #define _ALPHABET_INLINES_H_
  4.  
  5. #if NSTRING_DEBUG > 0
  6.     #include <stdio.h>
  7. #endif
  8.  
  9. //________________________________________________________________________
  10.  
  11. inline Alphabet::Alphabet (void)
  12. {
  13.     
  14. #if (NSTRING_DEBUG & 1) != 0
  15.     printf("Creating empty alphabet.\n");
  16. #endif
  17.  
  18.     clear();        
  19. }
  20.  
  21. //________________________________________________________________________
  22.  
  23. inline Alphabet Alphabet::operator+ (const char element) const
  24. {
  25.     Alphabet result(*this);                                                // copy this alphabet
  26.     
  27.     result += element;
  28.     return result;
  29. }
  30.  
  31. //________________________________________________________________________
  32.  
  33. Alphabet Alphabet::operator- (const char element) const
  34. {
  35.     Alphabet result(*this);                                                // copy this alphabet
  36.     
  37.     result -= element;
  38.     return result;
  39. }
  40.  
  41. //________________________________________________________________________
  42.  
  43. inline Alphabet Alphabet::operator+ (const char *source) const
  44. {
  45.     Alphabet result(*this);                                                // copy this alphabet
  46.     
  47.     result += source;
  48.     return result;
  49. }
  50.  
  51. //________________________________________________________________________
  52.  
  53. inline Alphabet Alphabet::operator+ (const NString& source) const
  54. {
  55.     Alphabet result(*this);                                                // copy this alphabet
  56.     
  57.     result += source;
  58.     return result;
  59. }
  60.  
  61. //________________________________________________________________________
  62.  
  63. inline Alphabet Alphabet::operator- (const char *source) const
  64. {
  65.     Alphabet result(*this);                                                // copy this alphabet
  66.     
  67.     result -= source;
  68.     return result;
  69. }
  70.  
  71. //________________________________________________________________________
  72.  
  73. inline Alphabet Alphabet::operator+ (const Alphabet& other) const
  74. {
  75.     Alphabet result(*this);                                                // copy this alphabet
  76.     
  77.     result += other;
  78.     return result;
  79. }
  80.  
  81. //________________________________________________________________________
  82.  
  83. inline Alphabet Alphabet::operator* (const Alphabet& other) const
  84. {
  85.     Alphabet result(*this);                                                // copy this alphabet
  86.     
  87.     result *= other;
  88.     return result;
  89. }
  90.  
  91. //________________________________________________________________________
  92.  
  93. inline Alphabet Alphabet::operator- (const Alphabet& other) const
  94. {
  95.     Alphabet result(*this);                                                // copy this alphabet
  96.     
  97.     result -= other;
  98.     return result;
  99. }
  100.  
  101. //________________________________________________________________________
  102.  
  103. inline Alphabet& Alphabet::operator*= (const char *string)
  104. {
  105.     Alphabet other(string);                                                // create an alphabet from the given string
  106.     
  107.     *this *= other;
  108.     return *this;
  109. }
  110.  
  111. //________________________________________________________________________
  112.  
  113. inline Alphabet& Alphabet::operator*= (const NString& string)
  114. {
  115.     Alphabet other(string);                                                // create an alphabet from the given string
  116.     
  117.     *this *= other;
  118.     return *this;
  119. }
  120.  
  121. //________________________________________________________________________
  122.  
  123. inline Alphabet Alphabet::operator* (const char *string) const
  124. {
  125.     Alphabet other(string);                                                // create an alphabet from the given string
  126.     Alphabet result(*this * other);
  127.     
  128.     return result;
  129. }
  130.  
  131. //________________________________________________________________________
  132.  
  133. inline Alphabet Alphabet::operator* (const NString& string) const
  134. {
  135.     Alphabet other(string);                                                // create an alphabet from the given string
  136.     Alphabet result(*this * other);
  137.     
  138.     return result;
  139. }
  140.  
  141. //________________________________________________________________________
  142.  
  143. inline Alphabet Alphabet::operator- (void) const
  144. {
  145.     Alphabet result(*this);                                                // copy this alphabet
  146.  
  147.     result.complement();
  148.     return result;
  149. }
  150.  
  151. //________________________________________________________________________
  152.  
  153. inline int Alphabet::operator== (const char *other) const
  154. {
  155.     Alphabet a(other);
  156.     return (*this == a);
  157. }
  158.  
  159. //________________________________________________________________________
  160.  
  161. inline int Alphabet::operator== (const NString& other) const
  162. {
  163.     Alphabet a(other);
  164.     return (*this == a);
  165. }
  166.  
  167. //________________________________________________________________________
  168.  
  169. inline int Alphabet::operator!= (const Alphabet& other) const
  170. {
  171.     return (! (*this == other));
  172. }
  173.  
  174. //________________________________________________________________________
  175.  
  176. inline int Alphabet::operator!= (const char *other) const
  177. {
  178.     Alphabet a(other);
  179.     return (! (*this == a));
  180. }
  181.  
  182. //________________________________________________________________________
  183.  
  184. inline int Alphabet::operator!= (const NString& other) const
  185. {
  186.     Alphabet a(other);
  187.     return (! (*this == a));
  188. }
  189.  
  190. //________________________________________________________________________
  191.  
  192. inline int Alphabet::operator<= (const Alphabet& other) const
  193. {
  194.     return ((*this * other) == *this);
  195. }
  196.  
  197. //________________________________________________________________________
  198.  
  199. inline int Alphabet::operator<= (const char *other) const
  200. {
  201.     Alphabet a(other);
  202.     return ((*this * a) == *this);
  203. }
  204.  
  205. //________________________________________________________________________
  206.  
  207. inline int Alphabet::operator<= (const NString& other) const
  208. {
  209.     Alphabet a(other);
  210.     return ((*this * a) == *this);
  211. }
  212.  
  213. //________________________________________________________________________
  214.  
  215. inline int Alphabet::operator< (const Alphabet& other) const
  216. {
  217.     return ((*this != other) && (*this <= other));
  218. }
  219.  
  220. //________________________________________________________________________
  221.  
  222. inline int Alphabet::operator< (const char *other) const
  223. {
  224.     Alphabet a(other);
  225.     return ((*this != a) && (*this <= a));
  226. }
  227.  
  228. //________________________________________________________________________
  229.  
  230. inline int Alphabet::operator< (const NString& other) const
  231. {
  232.     Alphabet a(other);
  233.     return ((*this != a) && (*this <= a));
  234. }
  235.  
  236. #endif
  237.